﻿using System;

/*
 * 创建人：Kewin
 * 
 * 时间：2010.8.4
 * 
 * 说明：抽象类相关概念
 * （1）抽象类是不能够实例化，引入抽象类是对类的再次抽象，即提取共性，去除个性的东西；
 * （2）抽象类可以不包含抽象方法；包含抽象成员的类必然是抽象类；
 * （3）抽象方法其实是隐式的虚方法，抽象方法不能提供实现而是由派生类利用override关键字实现；
 * （4）补充：类的静态方法尽可以访问静态成员；非静态方法可以访问静态和非静态成员和方法。
 * 修改说明：
 * 
 * 
 */


namespace ConsoleTest
{
    public abstract class BasedClass
    {
        public virtual void NewTestShow()
        {
            System.Console.WriteLine("Base NewTestShow");
        }
        public virtual void OverrideTestShow()
        {
            System.Console.WriteLine("Base OverrideTestShow");
        }
        
        public  abstract void AbstractTestShow();
        /// <summary>
        /// virtual的方法可以被override、也可被new
        /// </summary>
        public virtual void Function()
        {
            System.Console.WriteLine("Base Function");
        }
        public static void StaticFunction()
        {
            System.Console.WriteLine("Base StaticFunction");
        }
    }
    public class DerivedClass:BasedClass
    {
        public new void NewTestShow()
        {
            System.Console.WriteLine("Derived NewTestShow");
        }
        public override void OverrideTestShow()
        {
            System.Console.WriteLine("Derived OverrideTestShow");
        }
        public new void Function()
        {
            System.Console.WriteLine("Derived Function");
        }
        /// <summary>
        ///
        /// </summary>
        public override void AbstractTestShow()
        {
            System.Console.WriteLine("Derived AbstractTestShow");
        }
        public static new void StaticFunction()
        {
            System.Console.WriteLine("Derived StaticFunction");
        }
    }
    public class AbstractTest
    {
        public static void Test1()
        {
            BasedClass BaseEntity = new DerivedClass();
            BaseEntity.NewTestShow();
            BaseEntity.OverrideTestShow();
            BaseEntity.Function();
            DerivedClass d = new DerivedClass();
            d.Function();

        }
    }
}